<?php
namespace controllers;
use SDF\Controllers\Common;
use Model\suppliers;
use controllers\api;
class login extends Common{
        public function login(){
            self::display($this->DATA,'login/login');
        }
        public function dologin(){

             $user = $_REQUEST['user'];
             $password = $_REQUEST['pass'];
             $db = new suppliers();
             $supplier_info = $db->findOne(array('supplier_code'=>$user));

             if(empty($supplier_info)){
                 echo json_encode(array('status'=>true,'error'=>'用户不存在'));
                 exit;
             }
             if($password != '123456'){
                 echo json_encode(array('status'=>true,'error'=>'密码有误'));
                 exit;
             }
            session_start();
            $_SESSION['supplier_code']=$user;
            echo json_encode('200');
        }
        public function cancel(){
            session_start();
            session_unset();//free all session variable
            echo json_encode('200');
        }
}